package com.applet.applet_shangcheng.dao;

import com.applet.applet_shangcheng.entity.IntegralMalls;
import com.applet.applet_shangcheng.entity.Order;
import com.applet.applet_shangcheng.entity.ShufflingFigure;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    @Insert({
            "insert into tb_order（id,order_id,goods_name,goods_id,sum_number,sum_price,remit_money,actual_pay,create_time,update_time,pay_time,emission_time,article_time,delivery_number,username,consignee,phone,consignee_address,code,order_status,pay_status,emission_status,pay_mode）values(#{orderId},#{goodsName},#{sumNumber},#{sumPrice},#{remitMoney},#{actualPay},#{createTime},#{updateTime},#{payTime},#{emissionTime},#{articleTime},#{deliveryNumber},#{username},#{consignee},#{phone},#{consigneeAddress},#{code},#{orderStatus},#{payStatus},#{emissionStatus},#{payMode})"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertOrder(Order order);

    @Select({
            "select id,order_id,goods_name,goods_id,sum_number,sum_price,remit_money,actual_pay,create_time,update_time,pay_time,emission_time,article_time,delivery_number,username,consignee,phone,consignee_address,code,order_status,pay_status,emission_status,pay_mode from tb_order"
    })
    List<Order> getOrderList();

    Page<Order> findAll(String queryString);

    @Select({
            "select id,order_id,goods_name,goods_id,sum_number,sum_price,remit_money,actual_pay,create_time,update_time,pay_time,emission_time,article_time,delivery_number,username,consignee,phone,consignee_address,code,order_status,pay_status,emission_status,pay_mode from tb_order where id = #{id}"
    })
    Order getOrderById(@Param("id") int id);

    @Update({
            "update tb_order set  order_id=#{orderId},goods_name=#{goodsName},goods_id=#{goodsId},sum_number=#{sumNumber},sum_price=#{sumPrice},remit_money=#{remitMoney},actual_pay=#{actualPay},create_time=#{createTime},update_time=#{updateTime},pay_time=#{payTime},emission_time=#{emissionTime},article_time=#{articleTime},delivery_number=#{deliveryNumber},username=#{username},consignee=#{consignee},phone=#{phone},consignee_address=#{consigneeAddress},code=#{code},order_status=#{orderStatus},pay_status=#{payStatus},emission_status=#{emissionStatus},pay_mode=#{payMode} where id= #{id}"
    })
    int updateOrder(Order order);

    @Select({
            "select id,order_id,goods_name,goods_id,sum_number,sum_price,remit_money,actual_pay,create_time,update_time,pay_time,emission_time,article_time,delivery_number,username,consignee,phone,consignee_address,code,order_status,pay_status,emission_status,pay_mode from tb_order where order_id =#{order_id}"
    })
    Order findByOrderId(@Param("order_id") String order_id);

    @Insert({
            "update tb_order set order_status =#{orderStatus},pay_status =#{payStatus} where order_id =#{orderId}"
    })
    void save(Order order);

    @Select({
            "select sort_name from tb_integral_malls where table_t = tb_integral_goods"
    })
    List<String> getOrderClass();

    /*@Select({
            "SELECT order_name FROM tb_integral_order WHERE  pay_time LIKE #(time) "
    })*/
    int getHasPay(@Param("month")String month);

    int getNotPay(@Param("month")String month);

    List<Map<String,Object>> getHasGoodsNameList(@Param("time")String time);

    List<Map<String,Object>> getHasIGoodsNameList(@Param("time")String time);
}






